package com.xjscrm.console.chat.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * frame消息类型
 *
 * @author mingyang.chen create in 2024/3/11 17:56
 */
@Getter
@AllArgsConstructor
public enum ChatMsgType {

    heart_beat(1001, "心跳"),
    s_heart_beat(1002, "心跳响应"),

    r_staff_online(2002, "员工上线"),
    r_staff_offline(2003, "员工下线"),
    r_staff_leave(2004, "员工暂离"),

    r_session_reply(2005, "回复会话"),
    r_pull_device(2006, "拉取员工关联的机器人"),
    r_pull_session(2007, "拉取员工关联的会话"),
    r_pull_record(2008, "拉取会话的聊天记录"),
    r_pull_new_group_conversation(2009, "创建群聊会话-(使用场景: 群聊发起聊天时, 建群)"),
    r_pull_new_conversation(2010, "创建私聊会话-(使用场景: 私聊发起聊天时)"),
    r_conversation_set_remark(2011, "会话设置备注"),
    r_conversation_end(2012, "结束会话"),
    r_conversation_clean_all(2013, "清空所有会话"),
    r_conversation_msg_forward(2014, "会话消息转发"),
    r_conversation_msg_batch_forward(2015, "会话消息多条转发"),
    r_conversation_top(2016, "会话置顶"),
    r_conversation_shield(2017, "会话屏蔽"),
    r_conversation_silence(2018, "会话免打扰"),
    r_conversation_add_member(2019, "群聊会话添加成员"),
    r_conversation_kick_member(2020, "群聊会话移除成员"),
    r_conversation_expire(2021, "会话超时"),
    r_pull_all_session(2022, "拉取机器人的会话(包含聊天中或超时的)"),
    r_pull_customer(2023, "拉取机器人的好友"),
    r_pull_group(2024, "拉取机器人的群聊"),
    r_pull_group_conversation_members(2025, "拉取群会话的群成员"),
    r_set_group_admin(2026, "设置群聊会话管理员"),
    r_set_group_owner(2027, "设置群聊会话群主"),
    r_del_group_admin(2028, "删除群聊会话管理员"),
    r_conversation_exit(2029, "退出群聊"),
    r_pull_conversation_info(2030, "获取私聊会话信息-客户资料"),
    r_pull_group_conversation_info(2031, "获取群聊会话信息-群资料"),

    r_pull_device_all_session(2040, "获取机器人所有会话(包括超时或结束的会话)"),
    r_pull_device_customer(2041, "获取机器人客户(即好友)"),
    r_pull_device_group(2042, "获取机器人群聊"),
    r_get_device_info(2043, "获取机器人详情"),
    r_forward_record(2044, "转发单条消息"),
    r_forward_multi_record(2045, "转发多条消息"),
    r_read_msg(2046, "已读消息"),
    r_no_read_msg(2047, "未读消息"),
    r_recall_msg(2048, "撤回消息"),

    // done
    s_pull_device(3002, "拉取聊天中的机器人结果"),
    // done
    s_pull_talk_session(3003, "拉取聊天中的机器人对应的会话结果"),
    // done
    s_pull_record(3004, "拉取会话的聊天记录结果"),
    // done
    s_conversation_new_msg(3006, "会话新消息推送"),
    // done
    s_conversation_add_msg(3007, "新增会话推送"),
    // done
    s_conversation_del_msg(3008, "删除会话推送"),

    //
    s_staff_online(3009, "员工上线结果"),
    //
    s_staff_offline(3010, "员工下线结果"),
    //
    s_staff_leave(3011, "员工暂离结果"),
    //
    s_pull_session(3012, "拉取机器人的会话(包含聊天中或超时的)结果"),
    s_pull_customer(3013, "拉取机器人的好友结果"),
    s_pull_group(3014, "拉取机器人的群聊结果"),
    s_get_device_info(3015, "获取机器人详情结果"),
    s_conversation_end_notice(3016, "会话结束通知"),
    s_conversation_expire_notice(3017, "会话超时通知"),
    s_conversation_expired_notice(3018, "会话已经超时通知"),
    s_conversation_clean_notice(3019, "会话清除通知"),
    s_pull_conversation_result(3020, "获取私聊会话信息结果"),
    s_pull_group_conversation_result(3021, "获取群聊会话信息结果"),
    s_reply_success_result(3022, "会话回复成功结果"),
    s_recall_success_result(3023, "消息撤回成功"),
    s_get_staff_list_result(3024, "查询机器人关联员工列表结果"),
    s_session_count_result(3025, "查询会话数量结果"),

    s_401(401, "未认证"),
    s_success_msg(200, "成功消息"),
    s_error_msg(500, "错误消息"),
    ;

    private final Integer code;
    private final String desc;

    public static ChatMsgType getByCode(Integer code) {
        for (ChatMsgType value : ChatMsgType.values()) {
            if (Objects.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }

    public static String getAllDesc() {
        StringBuilder stringBuilder = new StringBuilder();
        for (ChatMsgType value : ChatMsgType.values()) {
            stringBuilder.append(value.getDesc()).append(":").append(value.getCode());
            stringBuilder.append(";");
        }
        return stringBuilder.toString();
    }
}
